package com.hfut.wxy.common.response;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONType;
import lombok.Getter;
import lombok.Setter;

@JSONType(serializeEnumAsJavaBean = true)
public enum Response {
    /*
    成功状态值
    */
    success("successful", new JSONObject(), 200),
    successDate("successful",null,200),
    error("error",new JSONObject(),4000),
    error4000("error",null,4000),
    error400("error",null,400),
    tokenException("token异常",null,4001),
    tokenInvalid("token失效",null,4002),
    verityFail("verify失败,请重试或确认学号密码",null,4003);

    private String message;
    private Object data;
    private Integer state;

    Response(String message, Object data, Integer state) {
        this.message = message;
        this.data = data;
        this.state = state;
    }

    public static  Response success(Object data){
        successDate.setData(data);
        return successDate;
    }

    public static  Response error(String msg){
        error4000.setMessage(msg);
        return error4000;
    }

    public static  Response errorMsg(String mes){
        error400.setMessage(mes);
        return error400;
    }





    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }
}
